home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Video Toaster 4.2
/
Video Toaster v4.2.iso
/
arexx
/
modeler
/
martianplumber.lwm
< prev
next >
Wrap
Text File
|
1993-12-13
|
6KB
|
259 lines
/* CMD: Weird Tubes
* Use the Martian Plumber to create strange tubes and connectors.. Nurnies!?
* This script was inspired by Ron Thorton of B5 fame, who uses weird things
* like this to adorn otherwise boring surfaces on space ships and such.
* Please add more modes and tricks to this, and send it back to me!!
* as an exersize for the reader: add a random twist to the tubes,
* Lathe random curves into tubes, add cool connector types,
* By Arnie Cachelin © 1993 NewTek Inc. */
ax.1='X'
ax.2='Y'
ax.3='Z'
call addlib "LWModelerARexx.port", 0
signal on error
signal on syntax
sysnam = 'Weird Tubes'
version = '1.0'
call req_begin sysnam
id_num = req_addcontrol("Segments", 'N')
id_len = req_addcontrol("Segment Length", 'N')
id_ind = req_addcontrol("Axis", "CH",'X Y Z Random')
id_cnt = req_addcontrol("Center", 'V', 0)
call req_setval id_num 1,1
call req_setval id_len 5,5
call req_setval id_cnt 0,0,0
if (~req_post()) then do
call req_end
exit
end
rand=1
TubeTypes=4
ConnectTypes=3
cen = req_getval(id_cnt)
parse var cen cx cy cz
/* cen= cx', 'cy', 'cz */
ax = req_getval(id_ind)
if ax=4 then ax =random(1,3,time('s'))
else rand=0
num = req_getval(id_num)
maxlen = req_getval(id_len)
call req_end
xrad=random(1,2,time('s')) /* Just a seed */
xrad=0.05*maxlen*(1+randu())
do tube=1 to num
typ=random(1,TubeTypes,time('S'))
len=0.5*maxlen*(1+randu())
rad=0.05*maxlen*(1+randu())
r=max(rad, xrad)
xrad=rad
ctyp=random(1,ConnectTypes,time('S'))
call SURFACE("Connector"||ctyp)
select
when ctyp=1 then do
call MAKEBALL(r,16,8,cen)
end
when ctyp=2 then do
call MAKEBOX(cx-r cy-r cz-r,cx+r cy+r cz+r,1)
end
when ctyp=3 then do
cax=random(1,3,time('S'))
t.1=cx
t.2=cy
t.3=cz
call MAKEDISC(r,t.cax-r,t.cax+r,Ax.cax,random(5,10,time(S)),1,cen)
end
end
if ax=1 then do
call MOVE(len 0 0)
end
if ax=2 then do
call MOVE(0 len 0)
end
if ax=3 then do
call MOVE(0 0 len)
end
call maketube(cen,len,rad,ax,typ)
cen= cx' 'cy' 'cz
if rand then ax=random(1,3,time('S'))
end
exit
syntax:
error:
t=Notify(1,'!Rexx Script Error','@'ErrorText(rc),'Line 'SIGL)
exit
MakeTube: PROCEDURE
arg cen, len, rad, ax,t
parse var cen cx' 'cy' 'cz
axlet=translate(ax,'XYZ','123')
call SURFACE("TubeType_"||t)
tb.1=cx
tb.2=cy
tb.3=cz
select
when t=1 then do
sides=random(3,16,time('s')) /* Rand Tube */
mrad=max(randu(),0.5)*rad
r.1=rad' 'rad' 'mrad
r.2=rad' 'rad' 'mrad
r.3=rad' 'mrad' 'rad
call MAKEDISC(r.ax, tb.ax,tb.ax+len,axlet,sides,1,cen)
end
when t=2 then do
sides=12 /* Tri-Tube */
cn.1=cx' 'cy+rad*.5' 'cz
cn.2=cx+rad*.5' 'cy' 'cz
cn.3=cx' 'cy+rad*.5' 'cz
call CUT()
call MAKEDISC(0.5*rad,tb.zx,tb.ax+len,axlet,sides,1,cn.ax)
call ROTATE(120,axlet,cx cy cz)
call MAKEDISC(0.5*rad,tb.zx,tb.ax+len,axlet,sides,1,cn.ax)
call ROTATE(120,axlet,cx cy cz)
call MAKEDISC(0.5*rad,tb.zx,tb.ax+len,axlet,sides,1,cn.ax)
call PASTE()
end
when t=3 then do
r=0.707*rad
lcorn.1=cx' 'cy+r' 'cz+r
hcorn.1=cx+len' 'cy-r' 'cz-r
lcorn.2=cx+r' 'cy' 'cz+r
hcorn.2=cx-r' 'cy+len' 'cz-r
lcorn.3=cx+r' 'cy+r' 'cz
hcorn.3=cx-r' 'cy-r' 'cz+len
caLL MAKEBOX(lcorn.ax,hcorn.ax,1)
if random(0,1,time('s')) then call ROTATE(45,axlet,cen)
end
when t=4 then do /* Accordion tube */
if ax="1" then do
y1=cy+rad
y2=cy+rad*(0.5*randu() + 0.25)
segs=random(2,5,time('s'))
dx=len/(2*segs)
x=cx
p=0
call CUT()
call add_begin
do i=1 to segs
vec= x y1 cz
call add_point vec
p=p+1
x=x+dx
call add_point x y2 cz
p=p+1
x=x+dx
call add_polygon p-1 p
call add_point x y1 cz
p=p+1
call add_polygon p-1 p
end
call add_end
call LATHE(axlet,random(3,16),cx cy cz)
call PASTE()
end
if ax="2" then do
x1=cx+rad
x2=cx+rad*(0.5*randu() + 0.25)
segs=random(2,5,time('s'))
dy=len/(2*segs)
y=cy
p=0
call CUT()
call add_begin
do i=1 to segs
call add_point x1 y cz
p=p+1
y=y+dy
call add_point x2 y cz
p=p+1
y=y+dy
call add_polygon p-1 p
call add_point x1 y cz
y=y+dy
p=p+1
call add_polygon p-1 p
end
call add_end
call LATHE(axlet,random(3,16),cx cy cz)
call PASTE()
end
if ax="3" then do
y1=cy+rad
y2=cy+rad*(0.5*randu() + 0.25)
segs=random(2,5,time('s'))
dz=len/(2*segs)
z=cz
p=0
call CUT()
call add_begin
do i=1 to segs
call add_point cx y1 z
p=p+1
z=z+dz
call add_point cx y2 z
p=p+1
z=z+dz
call add_polygon p-1 p
call add_point cx y1 z
z=z+dz
p=p+1
call add_polygon p-1 p
end
call add_end
call LATHE(axlet,random(3,16),cx cy cz)
call PASTE()
end
end
end
return t
Transform: /* Replace with a single new call */
arg mov, rot, scl, cnt
parse var rot rx','ry','rz
call SCALE(scl,cnt)
if rx~=0 then call ROTATE(rx,'X',cnt)
if ry~=0 then call ROTATE(ry,'Y',cnt)
if rz~=0 then call ROTATE(rz,'Z',cnt)
call MOVE(mov)
return
BevelText: Procedure /* Have flat text polygons ready! */
call BEVEL(0.015,0.015)
call COPY()
call UNDO()
call EXTRUDE('Z',0.1,1)
call PASTE()
return
Center: Procedure
box=boundingbox() /* Should check out empty list ... */
parse var box n x1 x2 y1 y2 z1 z2
cx=-(x2+x1)/2
cy=-(y2+y1)/2
cz=-(z2+z1)/2
call MOVE(cx cy cz)
return box
CenterAx: Procedure
arg A
box=boundingbox() /* Should check out empty list ... */
parse var box n x1 x2 y1 y2 z1 z2
cx=-(x2+x1)/2
cy=-(y2+y1)/2
cz=-(z2+z1)/2
say A cx cy cz
if ~pos(upper(A),'X') then cx=0
if ~pos(upper(A),'Y') then cy=0
if ~pos(upper(A),'Z') then cz=0
say cx cy cz
call MOVE(cx cy cz)
return box